
<script type="text/javascript">
	function doSearchConfig(value) {
		
	}
	
	//表格查询  
	function reloadConfig() {
		var params = config_list.datagrid('options').queryParams; //先取得 datagrid 的查询参数  
		printLog(params);
		config_list.datagrid('reload'); //设置好查询参数 reload 一下就可以了  
		config_list.datagrid('unselectAll');
		config_list.datagrid('uncheckAll');
	}


	function addConfig() {
		createFromWindow("新增信息", "config.do?editConfig", "config.do?saveConfig",
				function(data) {
					reloadConfig();
				},true,1000,600);
	}
	
	function deleteConfig() {
		var rows = config_list.datagrid('getChecked');
	    if (rows&&rows.length>0){
	        $.messager.confirm('询问','你确认要删除吗?',function(r){
	            if (r){
	            	var ids = "";
	            	for(var i=0; i<rows.length; i++){
	            		ids += rows[i].id+",";
	            	}
	                $.post('config.do?deleteConfigItems',{ids:ids},function(result){
	                    if (result.success){
	                    	reloadConfig();    
	                    }
	                    showMsg(result.msg);
	                },'json');
	            }
	        });
	    }else {
	    	showMsg("请选择操作记录.");
	    }
	}

	function editConfig() {
		var rows = config_list.datagrid('getChecked');
		printLog(rows);
		if (rows&&rows.length>0) {
			if(rows.length>1) {
				showMsg('请选择一条操作记录.');
				return;
			}
			createFromWindow("编辑信息", "config.do?editConfig&configId=" + rows[0].id,
					"config.do?saveConfig", function(data) {
						reloadConfig();
					},true,1000,600);
		} else {
			showMsg('请选择操作记录.');
		}

	}
	
	
	//操作按钮触发
	function operationsLookConfig(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = config_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			createFromWindow("查看信息", "config.do?editConfig&configId=" + id,
					null, null,false,1000,600);
		} else {
			showMsg('请选择查看记录.');
		}
	}
	
	function operationsEditConfig(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = config_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			createFromWindow("编辑信息", "config.do?editConfig&configId=" + id,
					"config.do?saveConfig", function(data) {
						reloadConfig();
					},true,1000,600);
		} else {
			showMsg('请选择编辑记录.');
		}
	}
	
	function operationsReadConfig(id) {
		printLog('预览'+id);
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = config_list.datagrid('getSelections');
			id = rows[0].id;
		}
		printLog(id);
		if (id) {
			//记得先自动选中
			config_list.datagrid('selectRecord',id);
			var record = config_list.datagrid('getSelected');
			printLog(record);
			window.mainpage.clickMenuAddModelTab(id,record.name,'12','readReport.do?configReportPage&configId='+id,'icon-standard-application-form',false);
		} else {
			showMsg('请选择记录.');
		}
	}
	
	function operationsDeleteConfig(id) {
		if (id == undefined) {//点击右键菜单才会触发这个
			var rows = new_list.datagrid('getSelections');
			id = rows[0].id;
		}
		if (id) {
			$.messager.confirm('询问', '你确认要删除吗?', function(r) {
				if (r) {
					$.post('config.do?deleteConfigItems', {
						ids:id
					}, function(result) {
						if (result.success) {
							reloadConfig(); 
						}
						showMsg(result.msg);
					}, 'json');
				}
			});
		} else {
			showMsg("请选择操作记录.");
		}
	}
</script>

<#assign operations = "[\{shiro:'report:config:refresh',onClick:'operationsLookConfig',src:'static/jmax/images/notes/note.png',title:'查看'},
	   					\{shiro:'report:config:edit',onClick:'operationsEditConfig',src:'static/jmax/images/notes/note_edit.png',title:'编辑'},
	   					\{shiro:'report:config:read',onClick:'operationsReadConfig',src:'static/jmax/images/notes/note_go.png',title:'预览'},
	   					\{shiro:'report:config:delete',onClick:'operationsDeleteConfig',src:'static/jmax/images/notes/note_delete.png',title:'删除'}
	  				   ]"/>

<div class="easyui-layout" data-options="fit:true">
	<div data-options="region:'center',border:false">
		
		<@eu.datagrid id="config_list" toolbar="#configlist_search" idField="id" operations="${operations!}"
			 url="config.do?loadList" rownumbers="true"
			 item="com.xdtech.report.vo.ConfigItem"/>
		
		<div id="configlist_search">
			<div id="config_toolbar" style="height: auto">
				
				<@eu.linkbutton showName="新增" shiro="report:config:add" iconCls="icon-add" onclick="addConfig()"/>
				<@eu.linkbutton showName="删除" shiro="report:config:delete" iconCls="icon-remove" onclick="deleteConfig()"/>
				<@eu.linkbutton showName="编辑" shiro="report:config:edit" iconCls="icon-edit" onclick="editConfig()"/>
				<@eu.linkbutton showName="刷新" shiro="report:config:refresh" iconCls="icon-reload" onclick="reloadConfig()"/>
				
			</div>
		</div>
	</div>
</div>